home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.7 KB | 74 lines | [TEXT/CWIE] |
- // DowncastLoop.h
-
- #ifndef DowncastLoop_h
- #define DowncastLoop_h
-
- template < class Inherited,
- class HeadType,
- class HeadBase,
- class NodeType,
- class NodeBase >
- class DowncastLoop: private Inherited
- {
- typedef ListLoop<Target> LoopType;
-
- private:
- static const NodeType *DownCast( const NodeBase *n )
- {
- return static_cast< const NodeType* >( n );
- }
-
- static const HeadType& DownCast( const HeadBase& n )
- {
- return static_cast< const HeadType& >( n );
- }
-
- public:
- DowncastLoop( const HeadType& h ) : Inherited( h ) {}
- DowncastLoop( const HeadType& h, AtStart ) : Inherited( h, atStart ) {}
- DowncastLoop( const HeadType& h, AtEnd ) : Inherited( h, atEnd ) {}
- DowncastLoop( const HeadType& h, Nowhere ) : Inherited( h, nowhere ) {}
- DowncastLoop( const HeadType& h, const NodeType& p ) : Inherited( h, p ) {}
- DowncastLoop( const HeadType& h, Before, const NodeType& p ) : Inherited( h, before, p ) {}
- DowncastLoop( const HeadType& h, After, const NodeType& p ) : Inherited( h, after, p ) {}
- DowncastLoop( const HeadType& h, BeforeStart ) : Inherited( h, beforeStart ) {}
- DowncastLoop( const HeadType& h, AfterEnd ) : Inherited( h, afterEnd ) {}
-
- const HeadType& Owner() const { return DownCast( Inherited::Owner() ); }
-
- Inherited::Finished;
- Inherited::Unfinished;
-
- Inherited::MoveToFinish;
- Inherited::MoveToFirst;
- Inherited::MoveToLast;
- Inherited::MoveBeforeFirst;
- Inherited::MoveAfterLast;
-
- void MoveTo( const NodeType& p ) { Inherited::MoveTo( p ); }
- void MoveBefore( const NodeType& p ) { Inherited::MoveBefore( p ); }
- void MoveAfter( const NodeType& p ) { Inherited::MoveAfter( p ); }
-
- bool operator==( const LoopType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const LoopType& r ) const { return Inherited::operator!=( r ); }
-
- bool operator==( const NodeType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const NodeType& r ) const { return Inherited::operator!=( r ); }
-
- Inherited::Null;
- const LinkType *Position() const { return DownCast( Inherited::Position() ); }
-
- const NodeType *Next() const { return DownCast( Inherited::Next() ); }
- const NodeType *Previous() const { return DownCast( Inherited::Previous() ); }
-
- const NodeType& operator*() const { return *DownCast( Inherited::operator->() ); }
- const NodeType *operator->() const { return DownCast( Inherited::operator->() ); }
-
- void operator++() { Inherited::operator++(); }
- void operator++(int) { Inherited::operator++(0); }
- void operator--() { Inherited::operator--(); }
- void operator--(int) { Inherited::operator--(0); }
- };
-
- #endif
-